import 'package:cms/api/cms.dart';
import 'package:cms/models/cms_configuration_model.dart';
import 'package:common/dio/model.dart';
import 'package:common/export/bloc.dart';
import 'lara_press_cms_state.dart';

class LaraPressCmsCubit extends Cubit<LaraPressCmsState> {
  LaraPressCmsCubit() : super(LaraPressCmsState().init()) {
    getConfiguration();
  }

  void getConfiguration() async {
    try {
      LarapressResponse<CmsConfigurationModel> response =
          await LaraPressCmsApi().getConfiguration();
      emit(state.copyWith(configuration: response.data));
    } catch (e) {
      emit(state.copyWith(configuration: null));
    }
  }
}
